/*
 * @Author: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @Date: 2023-11-24 15:38:32
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2023-11-24 16:06:47
 * @FilePath: \WingsUpdater-main\inc\Result.h
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

#pragma once
#include <string>

enum class ErrorKind: int16_t 
{
    Ok = 0,
    Unknown = -1,
    FileNotExist = -2,
    DirNotExist = -3,
    InvalidOperation = -4,
    ImcompleteIo = -5,
    ExternalLibError = -6,
    OsRelatedError = -7,
    IncorrectChecksum = -8,
    InvalidData = -9,
    InitFailed = -10,
    ExecuteFailed = -11,
    Timeout = -12,
    Busy = -13,
    InvalidArgument = -14,
    OpenFailed = -15,
    Receiving = -16,
    NotPassiveMode = -17,
    InvalidMessageReceiver = -18
};

struct Result 
{
public:
    ErrorKind m_kind;
    std::string m_message;
public:
    static Result create(ErrorKind kind, const std::string &customizedInfo = "")noexcept;
    Result(ErrorKind kind = ErrorKind::Ok);
    virtual ~Result() = default;
    Result(const Result &another)noexcept;
    Result(Result &&another)noexcept;
    Result &operator=(const Result &rhs)noexcept;
    Result &operator=(Result &&rhs)noexcept;
    bool operator==(const Result &rhs)const noexcept;
    bool operator!=(const Result &rhs)const noexcept;
    bool isOk()const noexcept;
    explicit operator int()const noexcept;
    operator std::string()const noexcept;
    std::string toString()const noexcept;
    void appendInfo(const std::string &info)noexcept;
    int code()const noexcept;
    const std::string &message()const noexcept;
};
